Hardware demapping of TLBs shared by multiple threads

ABSTRACT

In one embodiment, a processor comprising at least one translation lookaside buffer (TLB) and a control unit coupled to the TLB. The control unit is configured to track whether or not at least one update to the TLB is pending for at least one of a plurality of strands. Each strand comprises hardware to support a different thread of a plurality of concurrently activateable threads in the processor. The strands share the TLB, and the control unit is configured to delay a demap operation issued from one of the estrands responsive to the pending update, if any.

BACKGROUND

1. Field of the Invention

This invention is related to translation lookaside buffers (TLBs) anddemapping of translations in the TLBs, especially in multithreadedprocessors.

2. Description of the Related Art

Processors and computer systems that include the processors typicallyimplement a virtual memory system, in which most software executing onthe processors and accessing memory do so using virtual (or effective)addresses. These addresses are translated through the virtual memorysystem to physical addresses, which are used to access memory. A virtualmemory system offers several benefits: it allows software to address alarger virtual memory space than the actual physical memory included inthe system; it allows multiple independent processes to access memorywhile being protected from interfering with each other (e.g. by oneprocess modifying data used by another process); etc.

Generally, the virtual memory system (and particularly the mapping ofvirtual addresses to physical addresses) is under software control.Software builds data structures in memory that describe the virtual tophysical mappings. These data structures are usually referred to as“page tables”, since many translations translate a page of the virtualaddress space to a page of physical memory, aligned to a page boundaryin the physical memory space. Page sizes vary, from 4 kilobytes toseveral megabytes or even larger. A given virtual memory system oftensupports more than one page size.

Performing a translation frequently requires several accesses to thepage tables in memory. Even if the page tables are cached, the processof searching the page table entries is a lengthy process, as compared tothe amount of time needed to execute a given instruction. The addedlatency on memory accesses (both instruction fetches and load/storeoperations) to perform the translation process each time would hamperperformance. Accordingly, most processors implement a cache for a subsetof the translations from the page tables, referred to as a translationlookaside buffer (TLB). The TLB caches the results of the translationprocess, which includes an identification of the virtual address and thecorresponding physical address, as well as any protection data that maybe included in the virtual memory system (again, generally under thecontrol of software). The data cached in the TLB and used to translate agiven range of virtual addresses (e.g. a page) is referred to as a“translation” for the range/page. The translation may include contentsderived from multiple page table entries or one page table entry,depending on the definition of the virtual memory system.

At various points in time, the software that controls the virtual memorysystem (referred to as memory management software) needs to reclaimphysical memory that is currently mapped (e.g. to map other virtualaddresses to the physical memory). To reclaim physical memory, thememory management software invalidates the current mappings to thephysical memory in the page tables and establishes the new mappings.However, the old translations may be cached in the TLBs. Accordingly,the memory management software, after modifying the page tables, mustalso ensure that any translations derived from the invalidated pagetable entries are invalided in the TLBs.

In a single-threaded processor, it is sufficient for the memorymanagement software to issue a TLB translation removal operation(referred to herein as a demap operation) on the processor and the TLB(or TLBs) in the processor will be invalidated. In multiprocessorsystems, the TLBs on each processor must be invalidated. In some cases,the demap operation is issued on each processor. In the PowerPCarchitecture, two instructions are used to invalidate TLBs in amultiprocessor system: a TLB invalidate instruction (tlbie) that istransmitted by the executing processor to all other processors, and aTLB synchronization instruction (tlbsync) that follows the tlbie. Theexecuting processor also transmits the tlbsync to all other processors,which retry the tlbsync until the TLB invalidation is complete. When thetlbsync is successfully transmitted without retry, all TLBs are known tobe invalidated. Since the tlbsync is retried until a TLB invalidation iscomplete, the possibility of livelock exists if two processors areexecuting the tlbie/tlbsync sequence at the same time. Thus, softwaremust ensure that only one processor executes the code sequence thatincludes the tlbie/tlbsync. Additional instructions may also be required(e.g. a synchronization instruction (sync) prior to the tlbie).

In a multithreaded processor, hardware is provided to support eachthread that can be concurrently active in the processor. The hardwarethat supports a given thread is referred to as a “strand”. Strands mayshare a TLB. At any given point in time, two or more threads may have atranslation cached outside of the TLB. For example, the hardware tablewalker may have already read the translation, prior to page tablemodification and in response to a TLB miss for a thread on anotherstrand that shares the TLB, but not yet loaded it into the TLB.Alternatively, the translation may be cached by memory managementsoftware executing in response to a page fault from another thread, suchas in registers that correspond to the strand or memory locationsseparate from the page tables. Accordingly, it is possible that, evenafter executing the demap operation on one strand, other threadsexecuting on other strands that share the TLB may cause the translationto be reloaded in the TLB.

To prevent the reload after the demap operation, memory managementsoftware typically issues the demap operation on each strand that mayshare the TLB. Once the demap operation has completed on each strand,the translation is known to be invalidated in the TLB and will not bereloaded (since the translation is invalidated in the page tables and isno longer cached with respect to other active threads). Whilefunctionally correct, this solution is a low performance mechanism sincethe thread executing on each strand must be interrupted to perform thedemap operation.

SUMMARY

In one embodiment, a processor comprising at least one translationlookaside buffer (TLB) and a control unit coupled to the TLB. Thecontrol unit is configured to track whether or not at least one updateto the TLB is pending for at least one of a plurality of strands. Eachstrand comprises hardware to support a different thread of a pluralityof concurrently activateable threads in the processor. The strands sharethe TLB, and the control unit is configured to delay a demap operationissued from one of the strands responsive to the pending update, if any.A similar method is also contemplated.

In another embodiment, a processor comprises a plurality of strands,wherein each strand comprises hardware to support a different thread ofa plurality of concurrently activateable threads in the processor. Theprocessor further comprises at least one TLB shared by two or morestrands of the plurality of strands. Coupled to the TLB, a control unitis configured to delay a demap operation issued from a first strand ofthe two or more strands responsive to a pending update to the TLB.

BRIEF DESCRIPTION OF THE DRAWINGS

The following detailed description makes reference to the accompanyingdrawings, which are now briefly described.

FIG. 1 is a block diagram of one embodiment of a processor.

FIG. 2 is a block diagram of one embodiment of a core shown in FIG. 1.

FIG. 3 is a pipeline diagram illustrating one embodiment of a pipelinethat may be implemented by the core shown in FIG. 1.

FIG. 4 is a block diagram of a portion of one embodiment of a core shownin greater detail.

FIG. 5 is a flowchart illustration operation of one embodiment of acontrol unit in an MMU to track pending TLB updates.

FIG. 6 is a flowchart illustrating operation of one embodiment of a coreto process a demap operation.

FIG. 7 is a block diagram of a portion of one embodiment of a core shownin greater detail.

FIG. 8 is a block diagram of a portion of one embodiment of a processorillustrating one embodiment of broadcasting demap commands.

FIG. 9 is a flowchart illustrating operation of one embodiment of asource core that broadcasts a demap command.

FIG. 10 is a flowchart illustration operation of one embodiment of areceiving core that receives a broadcast demap command.

FIG. 11 is a block diagram of one embodiment of a computer systemincluding the processor shown in FIG. 1.

FIG. 12 is a timing diagram illustrating a potential reload of aninvalidated translation that is avoided by tracking pending TLB updatesand handling TLB demaps as described herein.

While the invention is susceptible to various modifications andalternative forms, specific embodiments thereof are shown by way ofexample in the drawings and will herein be described in detail. Itshould be understood, however, that the drawings and detaileddescription thereto are not intended to limit the invention to theparticular form disclosed, but on the contrary, the intention is tocover all modifications, equivalents and alternatives falling within thespirit and scope of the present invention as defined by the appendedclaims.

DETAILED DESCRIPTION OF EMBODIMENTS

Overview

FIGS. 1-3 present an overview of a multithreaded processor 10 that mayimplement the demap operations as described in more detail below. Inother embodiments, the processor may be implement other multithreadedconfigurations, as desired.

A block diagram illustrating one embodiment of a multithreaded processor10 is shown in FIG. 1. In the illustrated embodiment, processor 10includes a plurality of processor cores 100 a-h, which are alsodesignated “core 0” though “core 7”. Each of cores 100 is coupled to anL2 cache 120 via a crossbar 110. L2 cache 120 is coupled to one or morememory interface(s) 130, which are coupled in turn to one or more banksof system memory (not shown). Additionally, crossbar 110 couples cores100 to input/output (I/O) interface 140, which is in turn coupled to aperipheral interface 150 and a network interface 160. As described ingreater detail below, I/O interface 140, peripheral interface 150 andnetwork interface 160 may respectively couple processor 10 to bootand/or service devices, peripheral devices, and a network.

Cores 100 may be configured to execute instructions and to process dataaccording to a particular instruction set architecture (ISA). In oneembodiment, cores 100 may be configured to implement the SPARC® V9 ISA,although in other embodiments it is contemplated that any desired ISAmay be employed, such as x86, PowerPC® or MIPS®, for example. In theillustrated embodiment, each of cores 100 may be configured to operateindependently of the others, such that all cores 100 may execute inparallel. Additionally, as described below in conjunction with thedescriptions of FIG. 2 and FIG. 3, in some embodiments each of cores 100may be configured to execute multiple threads concurrently, where agiven thread may include a set of instructions that may executeindependently of instructions from another thread. (For example, anindividual software process, such as an application, may consist of oneor more threads that may be scheduled for execution by an operatingsystem.) Such a core 100 may also be referred to as a multithreaded (MT)core. In one embodiment, each of cores 100 may be configured toconcurrently execute instructions from eight threads, for a total of 64threads concurrently executing across processor 10. However, in otherembodiments it is contemplated that other numbers of cores 100 may beprovided, and that cores 100 may concurrently process different numbersof threads.

Crossbar 110 may be configured to manage data flow between cores 100 andthe shared L2 cache 120. In one embodiment, crossbar 110 may includelogic (such as multiplexers or a switch fabric, for example) that allowsany core 100 to access any bank of L2 cache 120, and that converselyallows data to be returned from any L2 bank to any core 100. Crossbar110 may be configured to concurrently process data requests from cores100 to L2 cache 120 as well as data responses from L2 cache 120 to cores100. In some embodiments, crossbar 110 may include logic to queue datarequests and/or responses, such that requests and responses may notblock other activity while waiting for service. Additionally, in oneembodiment crossbar 110 may be configured to arbitrate conflicts thatmay occur when multiple cores 100 attempt to access a single bank of L2cache 120 or vice versa.

L2 cache 120 may be configured to cache instructions and data for use bycores 100. In the illustrated embodiment, L2 cache 120 may be organizedinto eight separately addressable banks that may each be independentlyaccessed, such that in the absence of conflicts, each bank mayconcurrently return data to a respective core 100. In some embodiments,each individual bank may be implemented using set-associative ordirect-mapped techniques. For example, in one embodiment, L2 cache 120may be a 4 megabyte (MB) cache, where each 512 kilobyte (KB) bank is16-way set associative with a 64-byte line size, although other cachesizes and geometries are possible and contemplated. L2 cache 120 may beimplemented in some embodiments as a writeback cache in which written(dirty) data may not be written to system memory until a correspondingcache line is evicted.

In some embodiments, L2 cache 120 may implement queues for requestsarriving from and results to be sent to crossbar 110. Additionally, insome embodiments L2 cache 120 may implement a fill buffer configured tostore fill data arriving from memory interface 130, a writeback bufferconfigured to store dirty evicted data to be written to memory, and/or amiss buffer configured to store L2 cache accesses that cannot beprocessed as simple cache hits (e.g., L2 cache misses, cache accessesmatching older misses, accesses such as atomic operations that mayrequire multiple cache accesses, etc.). L2 cache 120 may variously beimplemented as single-ported or multiported (i.e., capable of processingmultiple concurrent read and/or write accesses). In either case, L2cache 120 may implement arbitration logic to prioritize cache accessamong various cache read and write requesters.

Memory interface 130 may be configured to manage the transfer of databetween L2 cache 120 and system memory, for example in response to L2fill requests and data evictions. In some embodiments, multipleinstances of memory interface 130 may be implemented, with each instanceconfigured to control a respective bank of system memory. Memoryinterface 130 may be configured to interface to any suitable type ofsystem memory, such as Fully Buffered Dual Inline Memory Module(FB-DIMM), Double Data Rate or Double Data Rate 2 Synchronous DynamicRandom Access Memory (DDR/DDR2 SDRAM), or Rambus® DRAM (RDRAM®), forexample. In some embodiments, memory interface 130 may be configured tosupport interfacing to multiple different types of system memory.

In the illustrated embodiment, processor 10 may also be configured toreceive data from sources other than system memory. I/O interface 140may be configured to provide a central interface for such sources toexchange data with cores 100 and/or L2 cache 120 via crossbar 110. Insome embodiments, I/O interface 140 may be configured to coordinateDirect Memory Access (DMA) transfers of data between network interface160 or peripheral interface 150 and system memory via memory interface130. In addition to coordinating access between crossbar 110 and otherinterface logic, in one embodiment I/O interface 140 may be configuredto couple processor 10 to external boot and/or service devices. Forexample, initialization and startup of processor 10 may be controlled byan external device (such as, e.g., a Field Programmable Gate Array(FPGA)) that may be configured to provide an implementation- orsystem-specific sequence of boot instructions and data. Such a bootsequence may, for example, coordinate reset testing, initialization ofperipheral devices and initial execution of processor 10, before theboot process proceeds to load data from a disk or network device.Additionally, in some embodiments such an external device may beconfigured to place processor 10 in a debug, diagnostic, or other typeof service mode upon request.

Peripheral interface 150 may be configured to coordinate data transferbetween processor 10 and one or more peripheral devices. Such peripheraldevices may include, without limitation, storage devices (e.g., magneticor optical media-based storage devices including hard drives, tapedrives, CD drives, DVD drives, etc.), display devices (e.g., graphicssubsystems), multimedia devices (e.g., audio processing subsystems), orany other suitable type of peripheral device. In one embodiment,peripheral interface 150 may implement one or more instances of aninterface such as Peripheral Component Interface Express (PCI-Express™),although it is contemplated that any suitable interface standard orcombination of standards may be employed. For example, in someembodiments peripheral interface 150 may be configured to implement aversion of Universal Serial Bus (USB) protocol or IEEE 1394 (Firewire®)protocol in addition to or instead of PCI-Express.

Network interface 160 may be configured to coordinate data transferbetween processor 10 and one or more devices (e.g., other computersystems) coupled to processor 10 via a network. In one embodiment,network interface 160 may be configured to perform the data processingnecessary to implement an Ethernet (EEEE 802.3) networking standard suchas Gigabit Ethernet or 10-Gigabit Ethernet, for example, although it iscontemplated that any suitable networking standard may be implemented.In some embodiments, network interface 160 may be configured toimplement multiple discrete network interface ports.

As mentioned above, in one embodiment each of cores 100 may beconfigured for multithreaded execution. More specifically, in oneembodiment each of cores 100 may be configured to perform fine-grainedmultithreading, in which each core may select instructions to executefrom among a pool of instructions corresponding to multiple threads,such that instructions from different threads may be scheduled toexecute adjacently. For example, in a pipelined embodiment of core 100employing fine-grained multithreading, instructions from differentthreads may occupy adjacent pipeline stages, such that instructions fromseveral threads may be in various stages of execution during a givencore processing cycle.

One embodiment of core 100 configured to perform fine-grainedmultithreading is illustrated in FIG. 2. In the illustrated embodiment,core 100 includes an instruction fetch unit (IFU) 200 coupled to amemory management unit (MMU) 250, a crossbar interface 260, a trap logicunit (TLU) 270, and a plurality of execution units (EXUO, EXUL) 210 a-b.(Execution units 210 a-b may also be referred to generically as EXUs210.) Each of execution units 210 a-b is coupled to both a floatingpoint/graphics unit (FGU) 220 and a load store unit (LSU) 230. Each ofthe latter units is also coupled to send data back to each of executionunits 210 a-b. Both FGU 220 and LSU 230 are coupled to a streamprocessing unit (SPU) 240. Additionally, LSU 230, SPU 240 and MMU 250are coupled to crossbar interface 260, which is in turn coupled tocrossbar 110 shown in FIG. 1.

Instruction fetch unit 200 may be configured to provide instructions tothe rest of core 100 for execution. In the illustrated embodiment, IFU200 includes a fetch unit 202, an instruction pick unit 206, and adecode unit 208. Fetch unit 202 further includes an instruction cache204. In one embodiment, fetch unit 202 may include logic to maintainfetch addresses (e.g., derived from program counters) corresponding toeach thread being executed by core 100, and to coordinate the retrievalof instructions from instruction cache 204 according to those fetchaddresses. In some embodiments, instruction cache 204 may include feweraccess ports than the number of threads executable on core 100, in whichcase fetch unit 202 may implement arbitration logic configured to selectone or more threads for instruction fetch during a given executioncycle. For example, fetch unit 202 may implement aleast-recently-fetched algorithm to select a thread to fetch. Fetch unit202 may also implement logic to handle instruction cache misses andtranslation of virtual instruction fetch addresses to physical addresses(e.g., fetch unit 202 may include an Instruction Translation LookasideBuffer (ITLB)). Additionally, in some embodiments fetch unit 202 mayinclude logic to predict branch outcomes and/or fetch target addresses,such as a Branch History Table (BHT), Branch Target Buffer (BTB), orother suitable structure, for example.

In one embodiment, fetch unit 202 may be configured to maintain a poolof fetched, ready-for-issue instructions drawn from among each of thethreads being executed by core 100. For example, fetch unit 202 mayimplement a respective instruction buffer corresponding to each threadin which several recently-fetched instructions from the correspondingthread may be stored. In one embodiment, instruction pick unit 206 maybe configured to select one or more instructions to be decoded andissued to execution units 210. In the illustrated embodiment, thethreads fetched by fetch unit 202 may be divided into two thread groupsdenoted TG0 and TG1 (for example, if core 100 implements eight threads,each of TG0 and TG1 may include four threads).

Pick unit 206, in the illustrated embodiment, may be configured toattempt to select one instruction to schedule for execution from each ofTG0 and TG1, such that two instructions may be selected for executionduring a given execution cycle. For example, pick unit 206 may employ aleast-recently-picked (LRP) algorithm in which the least recently pickedthread within a given thread group that is ready for execution isselected. It is noted that in one embodiment, thread fetching asperformed by fetch unit 202 and instruction selection as performed bypick unit 206 may be largely independent of one another. In someembodiments, pick unit 206 may schedule instructions before all factorsaffecting instruction scheduling are known (e.g., instructiondependencies, implementation-specific resource hazards, etc.), in whichcase a picked instruction may be canceled at a later execution stage. Inother embodiments, it is contemplated that other instruction selectionalgorithms may be employed, including algorithms that take additionalinstruction scheduling factors into account. Further, it is contemplatedthat in some embodiments, pick unit 206 may be configured to select morethan two instructions for execution in a given execution cycle, or mayselect instructions from all threads rather than specific groups ofthreads. Additionally, in one embodiment pick unit 206 may be configuredto identify source operand dependencies that a given picked instructionmay have on a previously issued instruction, and may configure otherlogic to appropriately select source operands (e.g., from a registerfile, or from a previous execution cycle via bypass logic).

Decode unit 208 may be configured to further prepare instructionsselected by pick unit 206 for execution. In the illustrated embodiment,decode unit 208 may be configured to identify the specific type of agiven instruction, such as whether the instruction is an integer,floating point, load/store, or other type of instruction, as well as toidentify operands required by the given instruction. Additionally, inone embodiment decode unit 208 may be configured to detect and respondto scheduling hazards not detected during operation of pick unit 206.For example, in the illustrated embodiment, only one load store unit 230is provided. Consequently, if two load/store-type instructions werepicked for execution, decode unit 208 may be configured to cancel orstall one of those instructions and allow the other to be issued. Insuch an embodiment, decode unit 208 may employ an arbitration algorithmto determine which instruction to issue without favoring a particularthread or thread group. Numerous other types of scheduling and resourcehazards detectable by decode unit 208 are possible and contemplated.

In some embodiments, instructions from a given thread may bespeculatively issued from decode unit 208 for execution. For example, agiven instruction from a certain thread may fall in the shadow of aconditional branch instruction from that same thread that was predictedto be taken or not-taken, or a load instruction from that same threadthat was predicted to hit in data cache 235, but for which the actualoutcome has not yet been determined. In such embodiments, afterreceiving notice of a misspeculation such as a branch misprediction or aload miss, IFU 200 may be configured to cancel misspeculatedinstructions from a given thread as well as issued instructions from thegiven thread that are dependent on or subsequent to the misspeculatedinstruction, and to redirect instruction fetch appropriately.

Execution units 210 a-b may be configured to execute and provide resultsfor certain types of instructions issued from IFU 200. In oneembodiment, each of EXUs 210 may be similarly or identically configuredto execute certain integer-type instructions defined in the implementedISA, such as arithmetic, logical, and shift instructions. In theillustrated embodiment, EXUO 210 a may be configured to execute integerinstructions issued from TG0, while EXU1 210 b may be configured toexecute integer instructions issued from TG1. Further, each of EXUs 210may include an integer register file configured to store register stateinformation for all threads in its respective thread group. For example,if core 100 implements eight threads 0-7 where threads 0-3 are bound toTG0 and threads 4-7 are bound to TG1, EXUO 210 a may store integerregister state for each of threads 0-3 while EXUL 210 b may storeinteger register state for each of threads 4-7. It is contemplated thatin some embodiments, core 100 may include more or fewer than two EXUs210, and EXUs 210 may or may not be symmetric in functionality. Also, insome embodiments EXUs 210 may not be bound to specific thread groups ormay be differently bound than just described. Finally, in theillustrated embodiment instructions destined for FGU 220 or LSU 230 passthrough one of EXUs 210. However, in alternative embodiments it iscontemplated that such instructions may be issued directly from IFU 200to their respective units without passing through one of EXUs 210.

Floating point/graphics unit 220 may be configured to execute andprovide results for certain floating-point and graphics-orientedinstructions defined in the implemented ISA. For example, in oneembodiment FGU 220 may implement single-and double-precisionfloating-point arithmetic instructions compliant with the IEEE 754floating-point standard, such as add, subtract, multiply, divide, andcertain transcendental functions. Also, in one embodiment FGU 220 mayimplement Single Instruction Multiple Data (SIMD) graphics-orientedinstructions defined by a version of the SPARC Visual Instruction Set(VIS™) architecture, such as VIS 2.0. Additionally, in one embodimentFGU 220 may implement certain integer instructions such as integermultiply, divide, and population count instructions, and may beconfigured to perform multiplication operations on behalf of streamprocessing unit 240. Depending on the implementation of FGU 220, someinstructions (e.g., some transcendental or extended-precisioninstructions) or instruction operand or result scenarios (e.g., certaindenormal operands or expected results) may be trapped and handled oremulated by software.

In the illustrated embodiment, FGU 220 may be configured to storefloating-point register state information for each thread in afloating-point register file. In one embodiment, FGU 220 may implementseparate execution pipelines for floating point add/multiply,divide/square root, and graphics operations, while in other embodimentsthe instructions implemented by FGU 220 may be differently partitioned.In various embodiments, instructions implemented by FGU 220 may be fullypipelined (i.e., FGU 220 may be capable of starting one new instructionper execution cycle), partially pipelined, or may block issue untilcomplete, depending on the instruction type. For example, in oneembodiment floating-point add operations may be fully pipelined, whilefloating-point divide operations may block other divide/square rootoperations until completed.

Load store unit 230 may be configured to process data memory references,such as integer and floating-point load and store instructions as wellas memory requests that may originate from stream processing unit 240.In some embodiments, LSU 230 may also be configured to assist in theprocessing of instruction cache 204 misses originating from IFU 200. LSU230 may include a data cache 235 as well as logic configured to detectcache misses and to responsively request data from L2 cache 120 viacrossbar interface 260. In one embodiment, data cache 235 may beconfigured as a write-through cache in which all stores are written toL2 cache 120 regardless of whether they hit in data cache 235; in somesuch embodiments, stores that miss in data cache 235 may cause an entrycorresponding to the store data to be allocated within the cache. Inother embodiments, data cache 235 may be implemented as a write-backcache.

In one embodiment, LSU 230 may include a miss queue configured to storerecords of pending memory accesses that have missed in data cache 235such that additional memory accesses targeting memory addresses forwhich a miss is pending may not generate additional L2 cache requesttraffic. In the illustrated embodiment, address generation for aload/store instruction may be performed by one of EXUs 210. Depending onthe addressing mode specified by the instruction, one of EXUs 210 mayperform arithmetic (such as adding an index value to a base value, forexample) to yield the desired address. Additionally, in some embodimentsLSU 230 may include logic configured to translate virtual data addressesgenerated by EXUs 210 to physical addresses, such as a Data TranslationLookaside Buffer (DTLB).

Stream processing unit 240 may be configured to implement one or morespecific data processing algorithms in hardware. For example, SPU 240may include logic configured to support encryption/decryption algorithmssuch as Advanced Encryption Standard (AES), Data EncryptionStandard/Triple Data Encryption Standard (DES/3DES), or Ron's Code #4(RC4). SPU 240 may also include logic to implement hash or checksumalgorithms such as Secure Hash Algorithm (SHA-1, SHA-256), MessageDigest 5 (MD5), or Cyclic Redundancy Checksum (CRC). SPU 240 may also beconfigured to implement modular arithmetic such as modularmultiplication, reduction and exponentiation. In one embodiment, SPU 240may be configured to utilize the multiply array included in FGU 220 formodular multiplication. In various embodiments, SPU 240 may implementseveral of the aforementioned algorithms as well as other algorithms notspecifically described.

SPU 240 may be configured to execute as a coprocessor independent ofinteger or floating-point instruction execution. For example, in oneembodiment SPU 240 may be configured to receive operations and operandsvia control registers accessible via software; in the illustratedembodiment SPU 240 may access such control registers via LSU 230. Inanother embodiment SPU 240 may receive operations and operands decodedand issued from the instruction stream by IFU 200. In some embodiments,SPU 240 may be configured to freely schedule operations across itsvarious algorithmic subunits independent of other functional unitactivity. Additionally, SPU 240 may be configured to generate memoryload and store activity. In the illustrated embodiment, SPU 240 mayinteract directly with crossbar interface 260 for such memory activity,while in other embodiments SPU 240 may coordinate memory activitythrough LSU 230. In one embodiment, software may poll SPU 240 throughone or more control registers to determine result status and to retrieveready results, for example by accessing additional control registers. Inother embodiments, FGU 220, LSU 230 or other logic may be configured topoll SPU 240 at intervals to determine whether it has ready results towrite back. In still other embodiments, SPU 240 may be configured togenerate a trap when a result is ready, to allow software to coordinateresult retrieval and processing.

As previously described, instruction and data memory accesses mayinvolve translating virtual addresses to physical addresses. In oneembodiment, such translation may occur on a page level of granularity,where a certain number of address bits comprise an offset into a givenpage of addresses, and the remaining address bits comprise a pagenumber. For example, in an embodiment employing 4 MB pages, a 64-bitvirtual address and a 40-bit physical address, 22 address bits(corresponding to 4 MB of address space, and typically the leastsignificant address bits) may constitute the page offset. The remaining42 bits of the virtual address may correspond to the virtual page numberof that address, and the remaining 18 bits of the physical address maycorrespond to the physical page number of that address. In such anembodiment, virtual to physical address translation may occur by mappinga virtual page number to a particular physical page number, leaving thepage offset unmodified.

Such translations may be stored in an ITLB or a DTLB for rapidtranslation of virtual addresses during lookup of instruction cache 204or data cache 235. In the event no translation for a given virtual pagenumber is found in the appropriate TLB, memory management unit 250 maybe configured to provide a translation. In one embodiment, MMU 250 maybe configured to manage one or more translation tables stored in systemmemory and to traverse such tables (which in some embodiments may behierarchically organized) in response to a request for an addresstranslation, such as from an ITLB or DTLB miss. (Such a traversal mayalso be referred to as a page table walk.) In some embodiments, if MMU250 is unable to derive a valid address translation, for example if oneof the memory pages including a necessary page table is not resident inphysical memory (i.e., a page miss), MMU 250 may be configured togenerate a trap to allow a memory management software routine to handlethe translation. It is contemplated that in various embodiments, anydesirable page size may be employed. Further, in some embodimentsmultiple page sizes may be concurrently supported.

A number of functional units in the illustrated embodiment of core 100may be configured to generate off-core memory or I/O requests. Forexample, IFU 200 or LSU 230 may generate access requests to L2 cache 120in response to their respective cache misses. SPU 240 may be configuredto generate its own load and store requests independent of LSU 230, andMMU 250 may be configured to generate memory requests while executing apage table walk. Other types of off-core access requests are possibleand contemplated. In the illustrated embodiment, crossbar interface 260may be configured to provide a centralized interface to the port ofcrossbar 110 associated with a particular core 100, on behalf of thevarious functional units that may generate accesses that traversecrossbar 110. In one embodiment, crossbar interface 260 may beconfigured to maintain queues of pending crossbar requests and toarbitrate among pending requests to determine which request or requestsmay be conveyed to crossbar 110 during a given execution cycle. Forexample, crossbar interface 260 may implement a least-recently-used orother algorithm to arbitrate among crossbar requestors. In oneembodiment, crossbar interface 260 may also be configured to receivedata returned via crossbar 110, such as from L2 cache 120 or I/Ointerface 140, and to direct such data to the appropriate functionalunit (e.g., data cache 235 for a data cache fill due to miss). In otherembodiments, data returning from crossbar 110 may be processedexternally to crossbar interface 260.

During the course of operation of some embodiments of core 100,exceptional events may occur. For example, an instruction from a giventhread that is picked for execution by pick unit 206 may be not be avalid instruction for the ISA implemented by core 100 (e.g., theinstruction may have an illegal opcode), a floating-point instructionmay produce a result that requires further processing in software, MMU250 may not be able to complete a page table walk due to a page miss, ahardware error (such as uncorrectable data corruption in a cache orregister file) may be detected, or any of numerous other possiblearchitecturally-defined or implementation-specific exceptional eventsmay occur. In one embodiment, trap logic unit 270 may be configured tomanage the handling of such events. For example, TLU 270 may beconfigured to receive notification of an exceptional event occurringduring execution of a particular thread, and to cause execution controlof that thread to vector to a supervisor-mode software handler (i.e., atrap handler) corresponding to the detected event. Such handlers mayinclude, for example, an illegal opcode trap handler configured toreturn an error status indication to an application associated with thetrapping thread and possibly terminate the application, a floating-pointtrap handler configured to fix up an inexact result, etc.

In one embodiment, TLU 270 may be configured to flush all instructionsfrom the trapping thread from any stage of processing within core 100,without disrupting the execution of other, non-trapping threads. In someembodiments, when a specific instruction from a given thread causes atrap (as opposed to a trap-causing condition independent of instructionexecution, such as a hardware interrupt request), TLU 270 may implementsuch traps as precise traps. That is, TLU 270 may ensure that allinstructions from the given thread that occur before the trappinginstruction (in program order) complete and update architectural state,while no instructions from the given thread that occur after thetrapping instruction (in program) order complete or update architecturalstate.

In the illustrated embodiment, core 100 may be configured for pipelinedexecution, in which processing of new instructions may begin beforeolder instructions have completed, such that multiple instructions fromvarious threads may be in various stages of processing during a givencore execution cycle. A pipeline diagram illustrating the flow ofinteger instructions through one embodiment of core 100 is shown in FIG.3. In the illustrated embodiment, execution of integer instructions isdivided into eight stages, denoted Fetch (F), Cache (C), Pick (P),Decode (D), Execute (E), Memory (M), Bypass (B), and Writeback (W). Inother embodiments, it is contemplated that different numbers of pipestages corresponding to different types of functionality may beemployed. It is further contemplated that other pipelines of differentstructure and depth may be implemented for integer or otherinstructions. For example, floating-point instructions may execute in alonger pipeline than integer instructions.

The first four stages of the illustrated integer pipeline may generallycorrespond to the functioning of IFU 200. In one embodiment, during theFetch stage, one or more threads to fetch may be selected, andinstruction cache 204 may be accessed for the selected thread. Duringthe Cache stage, fetch unit 202 may determine whether the access of theprevious cycle hit or missed the cache. If the access hit, theinstructions read from the cache may be stored in instruction buffers.During the Pick stage, pick unit 206 may be configured in one embodimentto select at most two instructions to issue, one for each thread groupas described above. Source dependencies of the selected instructions onpreviously issued instructions may also be detected during the Pickstage. During the Decode stage, decode unit 208 may be configured todecode the selected instructions and to determine whether resourcehazards exist as described above. For integer operations, data operandsmay also be selected during the Decode stage. For example, operands maybe retrieved from an integer register file, or bypass logic may beconfigured to bypass operands from another pipe stage.

During the Execute stage, one or both of execution units 210 may beactive to compute an instruction result. If an instruction in theinteger execution pipeline is not a load or store instruction, in theillustrated embodiment it may be idle during the Memory and Bypassstages before its result is committed (i.e., written back to the integerregister file) in the Writeback stage. A load or store instruction mayhave its address calculated by one of execution units 210 during theExecute stage. During the Memory stage of a load instruction, data cache235 may be accessed, while during the Bypass stage, LSU 230 maydetermine whether a data cache hit or miss occurred. In the hit case,data may be forwarded to the appropriate execution unit 210 (e.g.,dependent on the thread group of the load instruction) to be committedduring the Writeback stage. In one embodiment, store instructions andload instructions that miss data cache 235 may execute with differentpipeline timing than shown in FIG. 3.

In the illustrated embodiment, integer instructions are depicted asexecuting back-to-back in the pipeline without stalls. In executioncycles 0 through 7, instructions from threads 0, 3, 6, 2, 7, 5, 1 and 4enter the Fetch stage, respectively, though in other embodiments,instructions may issue from various threads in a different orderaccording to the operation of pick unit 206. In some instances, otherinstructions issued prior to execution cycle 0 may also be in thepipeline. Additionally, in some embodiments, two different instructionsfrom the same or different threads may execute during the same pipelinestage. For example, in the illustrated embodiment of core 100, oneinteger instruction may be issued to each of execution units 210 in asingle cycle.

By execution cycle 7, it is noted that each stage of the pipeline holdsan instruction from a different thread in a different stage ofexecution, in contrast to conventional processor implementations thattypically require a pipeline flush when switching between threads orprocesses. In some embodiments, flushes and stalls due to resourceconflicts or other scheduling hazards may cause some pipeline stages tohave no instruction during a given cycle. However, in the fine-grainedmultithreaded processor implementation employed by the illustratedembodiment of core 100, such flushes and stalls may be directed to asingle thread in the pipeline, leaving other threads undisturbed.Additionally, even if one thread being processed by core 100 stalls fora significant length of time (for example, due to an L2 cache miss),instructions from another thread may be readily selected for issue, thusincreasing overall thread processing throughput.

TLB Demapping in a TLB Shared by Multiple Threads/Strands

As mentioned above, in one embodiment, each of the cores 100 may bemultithreaded. That is, each core 100 may include multiple strands,where each strand comprises the hardware that supports one thread. Thus,the number of strands per core is equal to the number of threads thatcan be concurrently active within the core (e.g. 8, in one embodiment).For example, in the embodiment of FIG. 2 as described above, a strandmay include the hardware within the IFU 200 to fetch instructions forthe corresponding thread and store the instructions for issue by thepick unit 206. A strand may share the instruction cache 204 with allother strands, and may share the decode unit 208 and the EXU 210 a or210 b with other strands in the same thread group. A strand may sharethe LSU 230 (including data cache 235), the FPU 220, and the SPU 240with all other strands. The amount of hardware sharing between strandsmay vary from embodiment to embodiment.

In a given core, two or more strands share a TLB (or TLBs). In oneembodiment shown in FIG. 4, all of the strands in a core share an ITLBand a DTLB. In other embodiments, there may be more than one TLB (ormore than one ITLB and more than one DTLB) in a core and subsets ofstrands may share a TLB. For example, the strands that form a giventhread group may share TLBs. Any amount of sharing may be implemented invarious embodiments.

The core 100, and more particularly the MMU 250 in the illustratedembodiment, may track whether or not a TLB update is pending for thestrands. A TLB update may be pending, for example, if a hardware tablewalk has been initiated in response to a TLB miss, or if a page faulttrap has been taken by a thread on one of the strands. If a demapoperation is issued on one of the strands, and a TLB update is pending,the core 100 may delay the demap operation until the pending TLB updatesare completed (or in the case of a page fault trap, until a return fromthe page fault occurs, whether or not a TLB update is performed in thepage fault handler). The demap operation is then processed, invalidatingthe identified translation(s) in the TLB(s). Any subsequently-initiatedTLB updates will obtain the new translation (and will not obtain the oldtranslation that has been removed from the page tables). Any previousupdates to the TLB that may have loaded the old translations will beinvalidated.

Accordingly, in one embodiment, the demap operation may be issued ononly one strand that shares a given TLB. The other strands may continueexecuting their assigned threads, without interruption for the demapoperation. If desired, when multiple demap operations are to beperformed, separate demap operations may be issued on each strand thatshares a TLB, parallelizing the demap operations. Furthermore, in oneembodiment, a potential reload of the invalidated translation from acached page table entry may be avoided. The potential reload isillustrated in FIG. 12, where execution on a strand i and a strand j areshown. Strands i and j share a TLB. In FIG. 12, time is shown increasingin a downward direction, as illustrated by the arrow on the left side.On strand i, a hardware table walk is initiated (or a page fault handleris invoked: a similar caching problem exists in either case). A pagetable entry is cached (either in the hardware table walk unit or insoftware-managed storage). Subsequently, software on strand jinvalidates the same page table entry that has been cached via strand i,and includes a demap operation to demap the translation in the TLB.Subsequent to the demap, the table walk or the page fault handlercompletes for strand i using the cached page table entry, and thetranslation is reloaded into the TLB (even though it is now invalidatedin the page tables in memory). The translation may subsequently beaccessed in the TLB, which is functionally incorrect. By detecting thepending TLB update initiated by strand i in FIG. 12, and delaying thedemap operation on strand j until the pending TLB update is no longerpending, reload of the translation after it has been invalidated in thepage tables in memory may be avoided. Delaying the demap operation isillustrated in FIG. 12 by the dotted arrow 400, moving the circled demapoperation to after the completion of the table walk or page faulthandling on strand i.

As used herein, a demap operation comprises any operation that isdefined to invalidate at least one translation in a TLB. In someembodiments, there may be several versions of demap operations. Forexample, demap operations may include demap page, which invalidates thetranslation for an identified page; demap context, which invalidatestranslations associated with virtual addresses in a given context (e.g.by process ID or another identifier that identifies the context); anddemap partition (which demaps all virtual addresses in a logicalpartition). Generally, a demap operation may demap translationsaccording to any translation attribute (e.g. virtual page number,context ID, partition ID, etc.). Demap operations may comprise one ormore instructions. For example, the instructions may be defined at theISA level (such at the tlbie described above). Alternatively, theinstruction may be a store to a specified address which is mapped to amemory-mapped register, and the store data may be the identifier of thevirtual page(s) to be demapped. In the SPARC ISA, for example, the storeis to an address mapped to a specified address space identifier (ASI)register that is defined to perform a demap for the virtual address(es)identified by the value written into the register. Any register may beused in other embodiments (e.g. an architecturally-specified register, amodel-specific register, etc.).

Turning now to FIG. 4, a portion of the core 100 shown in FIG. 2 for oneembodiment is shown in more detail. Cores 100 a-100 h may be instancesof the core 100, for example. Particularly, the IFU 200, the MMU 250,the LSU 230, and the crossbar interface 260 are shown. The IFU 200 andthe LSU 230 are coupled to the MMU 250, which is further coupled to thecrossbar interface 260. The LSU 230 and the IFU 200 may also be coupledto the crossbar interface 260 (e.g. see FIG. 2). In the illustratedembodiment, the IFU 200 includes an ITLB. The MMU 250 includes ahardware table walk unit (HW TW) 302, one or more crossbar queues 304coupled to the hardware table walk unit 302, a control unit 306 coupledto the hardware table walk unit 302, and a TLB update pending register308 coupled to the control unit 306. The crossbar queues 304 are coupledto the crossbar interface 260. The LSU 230 includes an ASI queue 310 anda DTLB 312. The LSU 230 is also configured to issue a flush threadindication (“flush thread” in FIG. 4). The control unit 306 may becoupled to receive a page fault signal and a return signal.

If the ITLB 300 detects a miss for a translation request (for a fetch inthe instruction cache 204), the IFU 200 may transmit a TLB reloadrequest to the MMU 250. The MMU 250 may initiate a table walk in thehardware table walk unit 302 responsive to the request. The hardwaretable walk unit 302 may be programmed with the base address of the pagetables, and may be designed to search the page tables for a translationaccording to the definition of the page tables and the defined algorithmfor accessing them for a given virtual address in the virtual memorysystem. For example, a portion of the virtual address may be used,sometimes in combination with a predefined hash function, as an indexinto the page tables. If the hardware table walk unit 302 successfullylocates a translation in the page tables, the MMU 250 may return thetranslation for storage in the ITLB 300. If no translation is found, theMMU 250 (and more particularly the hardware table walk unit 302) maysignal a hardware table walk miss (HW TW miss signal in FIG. 4). The MMU250 may signal the HW TW miss directly to the TLU 270 for handling.Alternatively, the MMU 250 may signal the HW TW miss to the IFU 200(dotted line in FIG. 4). If an instruction is to issue from the virtualpage for which no translation was located, a page fault may be signalledat that point.

Similarly, if the DTLB 312 detects a miss for a translation request (fora load or store data access in the data cache 235), the LSU 230transmits a TLB reload request to the MMU 250. The MMU 250 may eitherreturn a translation for storage in the DTLB 312 (successful table walk)or signal a HW TW miss (unsuccessful table walk). The MMU 250 may signalthe HW TW miss directly to the TLU 270, or to the LSU 230 (dotted linein FIG. 4), which may associate the HW TW miss with the correctload/store instruction.

The hardware table walk unit 302 may generate requests to the crossbarinterface 260 to read page table entries from the L2 cache 120 and/ormemory (and optionally to write page table entries, such as to update areference bit and/or change bit that may be used by software todetermine which entries have been accessed/updated). The crossbar queues304 may be used to store requests and corresponding data returned fromthe crossbar interface 260. In some embodiments, the requests may bepassed through the data cache 235 first, if page table entries arecacheable in the data cache 235, before being transmitted to thecrossbar queues 304.

The control unit 306 is configured to track whether or not one or morestrands have TLB updates pending, and may be configured to delay demapoperations issued on strands that share the TLB if at least one TLBupdate is pending. The control unit 306 may track the pending updates inthe TLB update pending register 308. The control unit 306 may trackpending updates in any fashion. For example, the register 308 may storea vector of bits, each bit corresponding to a strand. The bit may be setto indicate if a TLB update is pending on that strand, and may be clearto indicate that no update is pending. Such a vector may permit anycombination of hardware table walks and traps to memory managementsoftware (page faults) to be outstanding at a given point in time. Inother embodiments, the core 100 may limit the number of outstandinghardware table walks/page faults, and different representations may bestored in the TLB update pending register 308. For example, if only onehardware table walk or page fault is permitted to be outstanding in theprocessor core 100, a bit may be used to indicate whether or not a TLBupdate is pending. In some embodiments, the core 100 may also permitmultiple table walks to be outstanding per thread that shares the TLB.

The control unit 306 is coupled to the hardware table walk unit 302, andmay detect initiation of a table walk by the hardware table walk unit302 for a thread executing on a strand. The control unit 306 may recordthat a TLB update is pending for the strand in response to the tablewalk being initiated. Additionally, the control unit 306 may receive anindication of a page fault (“page fault” in FIG. 4) which may identifythe strand for which the page fault is detected. The control unit 306may record the strand as having a TLB update pending. The control unit306 may also receive an indication of which strands are executingthreads that return to a lower trap level (“return” in FIG. 4). In oneembodiment, both a table walk completion and a page fault return cause areturn to a lower trap level (e.g. the level at which the user codeexecutes). The control unit 306 may record no update pending in responseto the strand returning to a lower trap level.

The core 100 may also implement a mechanism to ensure that the demapoperation completes (e.g. the mechanism may ensure that the demapoperation is not delayed indefinitely due to subsequently-initiatedtable walks or page faults that cause the detection of pending TLBupdates). For example, in one embodiment, the core 100 (or the controlunit 306, in the illustrated embodiment) may prevent initiation of anysubsequent page faults or table walks when there is a pending demapoperation. In one embodiment, the control unit 306 may prevent the startof a hardware table walk when there is a pending demap operation. Toprevent a strand causing a page fault, the control unit 306 may set an“MMU busy” bit when a demap operation is pending so that other strandscannot access the MMU (a temporary hardware stall). In anotherembodiment, an additional register may be updated with the contents ofthe TLB Update Pending register 308 in response to queuing a demapoperation. This additional register effectively captures the state ofthe pending updates at the time the demap operation is queued, and isnot updated to reflected newly pending updates that occur after thedemap operation is queued. The additional register may be updated toindicate updates are not pending as hardware table walks complete andreturns to lower trap levels occur (similar to the TLB Update Pendingregister 308). The additional register may be used to determine when thedemap operation can be completed (i.e. when the additional register nolonger indicates any pending TLB updates). There may be one of theseadditional registers per thread, or one additional register may be usedthat updates each time a demap operation is queued (while retaining thepending updates from the previous update).

In this embodiment, demap operations are stores to specified ASIaddresses. Accordingly, the demap operations map be detected in the LSU230, when the address is generated for a store. The LSU 230 and the MMU250 (more particularly, the control unit 306) may communicate todetermine if the demap operation may proceed immediately, or if it is tobe delayed (stalled) in the LSU 230. For example, the control unit 306may transmit a signal to the LSU 230 indicating whether or not a TLBupdate is outstanding, and the LSU 230 may use the signal to determineif the demap operation is to be delayed. If the demap operation is notdelayed, the LSU 230 may process the demap in the DTLB 312 and may alsotransmit it to the IFU 200 (through the MMU 250, or directly to the IFU200) to process the demap in the ITLB 300. Processing the demap in a TLBmay include invalidating one or more translations in the TLB that areidentified by the demap. Demap operations may also be supported thattarget a specific TLB (e.g. only the ITLB 300 or only the DTLB 312). Insuch cases, the translation may be invalidated only in the targeted TLB.

In one embodiment, if the demap operation is delayed, the LSU 230 mayqueue the demap operation in the ASI queue 310. The LSU 230 may processASI register reads and writes from the ASI queue 310. If a demapoperation is queued in the ASI queue 310, the queued demap operation maytake precedence over an executing demap operation that has not beenenqueued yet. The LSU 230 may also signal that the thread containing thedemap operation is to be flushed if the demap operation is delayed(“flush thread” in FIG. 4). In one embodiment, the LSU 230 may signalthe TLU 270, which may coordinate the flushing of the thread andstalling the IFU 200 from fetching on the corresponding strand until thedemap operation completes. In another embodiment, the LSU 230 maypropagate the flush directly to the upstream pipeline stages. The TLU270 may restart fetching after the table walk completes or the pagefault returns. Each of these may be detected, in one embodimentimplementing the SPARC ISA, by a reduction in the trap level at whichthe corresponding thread is executing.

It is noted that, while the control unit 306 and the TLB update pendingregister 308 are illustrated within the MMU 250 in this embodiment, thecontrol unit 306 and TLB update pending register 308 may be locatedanywhere within the core 100, as desired.

Turning now to FIG. 5, a flowchart is shown illustrating operation ofone embodiment of the control unit 306 to maintain the TLB updatepending status for a strand. Similar operation may be performed inparallel for each strand in the core 100 (or for each strand that sharesthe same TLB, in some embodiments). While the blocks are shown in aparticular order in FIG. 5 for ease of understanding, blocks may beperformed in parallel in combinatorial logic in the control unit 306.For example, decision block 326 and block 328 may be independent ofblocks 320, 322, and 324 and may be implemented in parallel. Blocks,combinations of blocks, and/or the flowchart as a whole may be pipelinedover multiple clock cycles.

The embodiment illustrated by the flowchart of FIG. 5 may be used, e.g.,if pending TLB updates are represented by a bit vector having a bit foreach strand. The bit is set to indicate that a TLB update is pending andclear to indicate that no TLB update is pending. Other embodiments mayreverse the meanings of the set and clear states. If a hardware tablewalk is initiated for the thread executing on the strand (decision block320, “yes” leg) or a page fault trap to software occurs for the thread(decision block 322, “yes” leg), the control unit 306 may set the TLBupdate pending bit for the strand (block 324). If the thread executingon the strand returns to a lower trap level (decision block 326, “yes”leg), the control unit 306 may clear the TLB update pending bit for thestrand (block 328). Returning to a lower trap level may occur when thehardware table walk unit completes (successfully or unsuccessfully), orthe control unit 306 may detect the HW TW miss signal and may clear aTLB update pending bit for that strand that had its table walkcompleted.

Turning now to FIG. 6, a flowchart is shown illustrating operation ofone embodiment of the LSU 230 during execution of a store instruction.While the blocks are shown in a particular order in FIG. 6 for ease ofunderstanding, blocks may be performed in parallel in combinatoriallogic in the LSU 230. Blocks, combinations of blocks, and/or theflowchart as a whole may be pipelined over multiple clock cycles.

The LSU 230 may generate the virtual address for the store instructionfrom its operands. Alternatively, the EXUs 210 a-210 b may perform theaddress generation, and may supply the address to the LSU 230. The LSU230 may decode the address to determine if the address is mapped to theASI register used for demap operations. The LSU 230 may also decode theinstruction, immediate data, and/or machine state maintained by the core100 to detect the demap operation. If not (decision block 330, “no”leg), the LSU 230 may process the store instruction as normal (block332). Block 332 may include processing other ASI addresses that do notaddress the ASI register for demap operations, and may include enqueuingsuch operations in the ASI queue 310.

If the address is mapped to the ASI register used for demap operations(block 330, “yes” leg) and no TLB update is pending, as indicated bycontrol unit 306 (decision block 334, “no” leg), and the ASI queue 310is empty (decision block 335, “yes” leg), the LSU 230 may complete thedemap operation (block 336). As mentioned above, completing the demapoperation may include invalidating the translations indicated by thedemap operation in the DTLB 312, if any, and providing the demapoperation to the IFU 200 to invalidate the translations in the ITLB 300.If at least one TLB update is pending (decision block 334, “yes” leg),the LSU 230 may flush the thread from which the demap operation isissued (block 338) and may enqueue the demap operation in the ASI queue310, delaying the demap operation (block 340). The demap operation mayremain in the ASI queue 310 until no more TLB updates are pending, asindicated by the control unit 306. The LSU 310 may wait for the ASIqueue 310 to drain (block 342) and then may complete the demap operation(block 336). If no TLB updates are pending (decision block 334, “no”leg) and the ASI queue is not empty (decision block 335, “no” leg), theLSU 230 may enqueue the demap operation in the ASI queue 310 (block 340)and may wait for the ASI queue 310 to drain (block 342) beforecompleting the demap operation (block 336). If the thread was flusheddue to queuing of the demap operation in the ASI queue 310, the threadis refetched after the ASI queue 310 drains and the demap operationcompletes, to permit execution of the next instruction in the thread.

TLB Demapping Across Multiple Cores

In embodiments having multiple cores, the mechanism described aboveensures invalidations of TLBs in one core. The same process may berepeated, in some embodiments, on each core to invalidate the TLBsacross the processor 10. Other embodiments may implement the mechanismdescribed below to invalidate TLBs across multiple cores using a demapoperation executed in one core.

A processor core that executes a demap operation (a “source core”) maybe configured to broadcast a demap command over the interconnect thatcouples the cores, the L2 cache, and the memory system. The other cores(“receiving cores”) receive the demap command from the interconnect andmay process the demap command internally, invalidating the translationsidentified by the demap command in any TLBs in the core. Once theprocessing of the demap command is complete, the receiving cores maytransmit a response to the source core. Once the source core receivesresponses from each of the receiving cores, the demap operation may becompleted locally in the source core. Thus, once the demap operationcompletes, the TLBs across the processor 10 are known to be invalidated.Furthermore, using a request/response structure for performing the demapoperation may, in some cases, avoid a separate synchronization operationafter the demap operation. In some embodiments, multiple cores maytransmit demap commands concurrently, or overlapped in time, withoutconcern for livelock between the cores. If a large number of demapoperations are needed, they may be spread across multiple cores tofurther parallelize the demap, if desired.

A demap command may comprise a transmission on the interconnect thatcouples cores to the memory system. Thus, the demap command may beformatted according to the definition of transmissions on theinterconnect, and may differ from the demap operation executed within acore. The demap command further includes at least data that identifiesthe translation or translations to be invalidated (e.g. virtual page,context ID, partition ID, etc.). Other control information may beincluded in various embodiments.

The receiving cores may process the demap command in any desiredfashion. For example, the demap command may be processed in a similarmanner to internally executed demap operations. In one embodiment, theinternal demap operations may be processed as described above, bytracking the pending TLB updates and delaying completion of the demapoperation until there are no pending TLB updates. In such an embodiment,the same mechanism may be used to process the demap command in thereceiving cores. Such an embodiment is described in more detail below,but any mechanism may be used in general.

Turning now to FIG. 7, a block diagram of one embodiment of a portion ofthe core 100 for implementing broadcast of demap commands between coresis shown. The embodiment of FIG. 7 may be similar to the embodiment ofFIG. 4, and may include the ITLB 300 in the IFU 200 and the ASI queue310 and the DTLB 312 in the LSU 230. Also similar to embodiment of FIG.4, the embodiment of FIG. 7 may include the MMU 250 with the hardwaretable walk unit 302, crossbar queues 304, control unit 306, and TLBupdate pending register 308 coupled as shown in FIG. 4. Additionally,the control unit 306 is coupled to the crossbar queues 304 and there isa response count register 350 coupled to the control unit 306.

The internal processing of an executed demap operation may generally besimilar to the discussion above with regard to FIGS. 4-6. However, inaddition to delaying the demap operation if there is a pending TLBupdate, the control unit 306 may delay the demap operation to broadcasta corresponding demap command and await the responses from the receivingcores. That is, each demap operation may be delayed until thecommunication with other cores is completed. The control unit 306 isthus coupled to the crossbar queues 304 to transmit demap commands andto receive demap responses.

In one embodiment, the number of responses may be programmable in theresponse count register 350. For example, the response count register350 may be an ASI register, model specific register, etc. In otherembodiments, the response count may be fixed (e.g. at the number ofcores integrated into the processor 10 on a single integrated circuitsubstrate) or may be provided in other fashions (e.g. pin strapping,fuses blown at manufacture, etc.).

FIG. 8 is a block diagram of one embodiment of a portion of theprocessor 10. Illustrated in FIG. 8 are the cores 100 a-100 h and thecrossbar 110. Additionally, a broadcast/response unit 360 is shown. Thebroadcast/response unit 360 is coupled to the crossbar 110. In theembodiment of FIG. 1, the cores 100 a-100 h are coupled on one side ofthe crossbar 110 and the memory system is on the other. Thus, in thisembodiment, there is no direct communication between the cores 100 a-100h. The broadcast/response unit 360 may receive the broadcast demapcommand from the source core and transmit it to the receiving cores. Thebroadcast/response unit 360 may also receive the responses (“demapdone”) in FIG. 8 from the receiving cores and transmit the response tothe source core. In some embodiments, the broadcast/response unit 360may be part of another unit (e.g. a non-cacheable unit that handlesnon-cacheable memory accesses).

For example, in FIG. 8, the core 100 a transmits a demap command (solidarrow 364) on the crossbar 110. The broadcast/response unit 360 receivesthe demap command and transmits the demap command back across thecrossbar 110 to the other cores (e.g. core 100 b and 100 h, solid arrows366 and 368, respectively, in FIG. 8). The cores 100 b and 100 htransmit demap done responses on the crossbar 110 (dotted and dashedarrows 370 and 372, respectively). The broadcast/response unit 360receives the demap done responses and transmits the responses to thecore 100 a (dotted and dashed arrows 374 and 376, respectively).

While the illustrated embodiment uses the crossbar 110 and thebroadcast/response unit 360, in general any interconnect 362 may be usedthat permits a source core to broadcast a demap command to the receivingcores and that permits the receiving cores to return demap doneresponses to the source core. For example, a shared bus may be used;point to point links between cores, where cores relay commands from onecore to another may be used; direct point to point links between eachpair of cores may be used; etc.

Turning next to FIG. 9, a flowchart is shown illustrating operation ofone embodiment of a source core. Any core 100 a-100 h may be a sourcecore by executing a demap operation locally (that is, in its instructionpipeline). While the blocks are shown in a particular order in FIG. 9for ease of understanding, blocks may be performed in parallel incombinatorial logic in the source core. Blocks, combinations of blocks,and/or the flowchart as a whole may be pipelined over multiple clockcycles.

The source core detects a local demap operation (decision block 380,“yes” leg). If there is no local demap operation, there is no sourcecore operation. The source core transmits the broadcast demap command(block 382). Particularly, the control unit 306 may generate thebroadcast demap command and queue it in the crossbar queues 304, and thecrossbar interface 260 may read the demap command from the crossbarqueues 304 and transmit the demap command on the crossbar 110. Thesource core waits for the demap done responses to be received from eachreceiving core (decision block 384). As mentioned previously, in oneembodiment, the number of responses to expect may be programmed into theresponse count register 350. Once the response has been received fromeach receiving core, the source core may process the local demapoperation (e.g. waiting for no TLB updates to be pending, decision block386, and completing the demap operation by invalidating the identifiedtranslations in the TLBs, block 388). In other embodiments, theinvalidation of the local TLBs may take place when no updates arepending, independent of whether or not all of the responses have beenreceived from the receiving nodes. In such an embodiment, the controlunit 306 may signal the LSU 230 that the demap operation is completeafter the responses have been received and the local TLB invalidationshave occurred. Thus, in general, the processor core 100 may delaycontinued processing subsequent to the demap operation on the strandthat executed the demap operation until all the responses are received.

FIG. 10 is a flowchart illustrating operation of one embodiment of areceiving core. Any core 100 a-100 h may be a receiving core byreceiving a broadcast demap command. While the blocks are shown in aparticular order in FIG. 10 for ease of understanding, blocks may beperformed in parallel in combinatorial logic in the source core. Blocks,combinations of blocks, and/or the flowchart as a whole may be pipelinedover multiple clock cycles.

The receiving core may process the broadcast demap command in a similarfashion to the local demap operation (block 390). That is, the controlunit 306 may delay the demap until there are no pending TLB updates, andmay perform the invalidations in the TLBs. The receiving core may thentransmit a demap done response (block 392). For example, the controlunit 306 may generate the demap done response and enqueue it in thecrossbar queues 304, and the crossbar interface 260 may transmit thedemap done response on the crossbar 110.

Exemplary System Embodiment

As described above, in some embodiments processor 10 of FIG. 1 may beconfigured to interface with a number of external devices. Oneembodiment of a system including processor 10 is illustrated in FIG. 11.In the illustrated embodiment, system 800 includes an instance ofprocessor 10 coupled to a system memory 810, a peripheral storage device820 and a boot device 830. System 800 is coupled to a network 840, whichis in turn coupled to another computer system 850. In some embodiments,system 800 may include more than one instance of the devices shown, suchas more than one processor 10, for example. In various embodiments,system 800 may be configured as a rack-mountable server system, astandalone system, or in any other suitable form factor. In someembodiments, system 800 may be configured as a client system rather thana server system.

In various embodiments, system memory 810 may comprise any suitable typeof system memory as described above, such as FB-DIMM, DDR/DDR2 SDRAM, orRDRAM®, for example. System memory 810 may include multiple discretebanks of memory controlled by discrete memory interfaces in embodimentsof processor 10 configured to provide multiple memory interfaces 130.Also, in some embodiments system memory 810 may include multipledifferent types of memory.

Peripheral storage device 820, in various embodiments, may includesupport for magnetic, optical, or solid-state storage media such as harddrives, optical disks, nonvolatile RAM devices, etc. In someembodiments, peripheral storage device 820 may include more complexstorage devices such as disk arrays or storage area networks (SANs),which may be coupled to processor 10 via a standard Small ComputerSystem Interface (SCSI), a Fibre Channel interface, a Firewire® (IEEE1394) interface, or another suitable interface. Additionally, it iscontemplated that in other embodiments, any other suitable peripheraldevices may be coupled to processor 10, such as multimedia devices,graphics/display devices, standard input/output devices, etc.

As described previously, in one embodiment boot device 830 may include adevice such as an FPGA or ASIC configured to coordinate initializationand boot of processor 10, such as from a power-on reset state.Additionally, in some embodiments boot device 830 may include asecondary computer system configured to allow access to administrativefunctions such as debug or test modes of processor 10.

Network 840 may include any suitable devices, media and/or protocol forinterconnecting computer systems, such as wired or wireless Ethernet,for example. In various embodiments, network 840 may include local areanetworks (LANs), wide area networks (WANs), telecommunication networks,or other suitable types of networks. In some embodiments, computersystem 850 may be similar to or identical in configuration toillustrated system 800, whereas in other embodiments, computer system850 may be substantially differently configured. For example, computersystem 850 may be a server system, a processor-based client system, astateless “thin” client system, a mobile device, etc.

Numerous variations and modifications will become apparent to thoseskilled in the art once the above disclosure is fully appreciated. It isintended that the following claims be interpreted to embrace all suchvariations and modifications.

1. A processor comprising: at least one translation lookaside buffer(TLB); and a control unit coupled to the TLB and configured to trackwhether or not at least one potential update to the TLB is pending forat least one of a plurality of strands, wherein the update loads a validtranslation into the TLB, and wherein each strand comprises hardware tosupport a different thread of a plurality of concurrently active threadsin the processor, and wherein the plurality of strands share the TLB,and wherein the control unit is configured to delay a demap operationissued from one of the plurality of strands responsive to the pendingupdate, if any, issued from another one of the plurality of strands. 2.The processor as recited in claim 1 wherein, if there is no pendingupdate, the control unit is configured not to delay the demap operation.3. The processor as recited in claim 1 wherein the control unit isconfigured to delay the demap operation until there is no pendingupdate, and wherein the processor is configured to complete the demapoperation by invalidating one or more translations identified by thedemap operation in the TLB.
 4. The processor as recited in claim 3wherein the at least one TLB comprises an instruction TLB and a dataTLB, and wherein completing the demap operation comprises invalidatingthe one or more translations in one or both of the instruction TLB andthe data TLB.
 5. The processor as recited in claim 1 further comprisinga hardware table walk unit configured to search page tables in memoryfor a translation in response to a miss in the TLB, and wherein thecontrol unit is coupled to the table walk unit and is configured todetect the pending update responsive to a table walk being initiated inthe table walk unit.
 6. The processor as recited in claim 5 wherein thecontrol unit is configured to detect no pending update responsive to thehardware table walk unit completing the table walk.
 7. The processor asrecited in claim 6 wherein the control unit is configured to detect noupdate pending on return from the page fault.
 8. The processor asrecited in claim 1 wherein the control unit is configured to detect thepending update responsive to a trap for a page fault.
 9. The processoras recited in claim 1 further configured to inhibit subsequent TLBupdates from initiating until the demap operation is completed.
 10. Theprocessor as recited in claim 1 further comprising one or moreregisters, wherein one of the registers is configured to capture apending TLB update state in response to the demap operation, and whereinthe demap operation completes when the pending TLB updates recorded inthe pending TLB update state complete.
 11. A method comprising: trackingwhether or not at least one potential update to at least one translationlookaside buffer (TLB) is pending for at least one of a plurality ofstrands, wherein the update loads a valid translation into the TLB, andwherein each strand comprises hardware to support a different thread ofa plurality of concurrently active threads in a processor, and whereinthe plurality of strands share the TLB; and delaying a demap operationissued from one of the plurality of strands responsive to the pendingupdate issued from another one of the plurality of strands.
 12. Themethod as recited in claim 11 wherein the delaying is continued untilthere is no pending update, and the method further comprises completingthe demap operation by invalidating one or more translations identifiedby the demap operation in the TLB.
 13. The method as recited in claim 11wherein the processor comprises a hardware table walk unit configured tosearch page tables in memory for a translation in response to a miss inthe TLB, and wherein tracking whether or not the update is pendingcomprises detecting the pending update responsive to a table walk beinginitiated in the table walk unit.
 14. The method as recited in claim 13wherein tracking whether or not the update is pending comprisesdetecting no pending update responsive to the hardware table walk unitcompleting the table walk.
 15. The method as recited in claim 11 whereintracking whether or not the update is pending comprises detecting thepending update responsive to a trap for a page fault.
 16. The method asrecited in claim 15 wherein tracking whether or not the update ispending comprises detecting no update pending on return from the pagefault.
 17. A processor comprising: a plurality of strands, wherein eachstrand comprises hardware to support a different thread of a pluralityof concurrently active threads in the processor; at least onetranslation lookaside buffer (TLB) shared by two or more strands of theplurality of strands; and a control unit coupled to the TLB andconfigured to delay a demap operation issued from a first strand of thetwo or more strands responsive to a pending update to the TLB issuedfrom a second strand of the two or more strands, wherein the pendingupdate loads a valid translation into the TLB.
 18. The processor asrecited in claim 17 wherein, if there is no pending update, the controlunit is configured not to delay the demap operation.
 19. The processoras recited in claim 17 wherein the control unit is configured to delaythe demap operation until there is no pending update, and wherein theprocessor is configured to complete the demap operation by invalidatingone or more translations identified by the demap operation in the TLB.20. The processor as recited in claim 17 further comprising a hardwaretable walk unit configured to search page tables in memory for atranslation in response to a miss in the TLB, and wherein the controlunit is coupled to the table walk unit and is configured to detect thepending update responsive to a table walk being initiated in the tablewalk unit and wherein the control unit is further configured to detectthe pending update responsive to a trap for a page fault.